﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hi_Baidu.FileShare.Interface;
using System.Windows.Forms;

namespace Hi_Baidu.FileShare
{
    public delegate void AddFileShareEvent(object Sender, Hi_Baidu.FileShare.FileShareProcessorCollection.OnAddFileShareEventArgs e);
    public class FileShareProcessorCollection : MarshalByRefObject
    {
        public List<FileShareProcessor> FileShareProcessors = new List<FileShareProcessor>();
        public static event AddFileShareEvent AddFileShareEventArgs;
        public void OnAddFileShare(Hi_Baidu.FileShare.FileShareProcessorCollection.OnAddFileShareEventArgs e)
        {
            if (AddFileShareEventArgs != null)
            {
                AddFileShareEventArgs(this, e);
            }
        }

        /// <summary>
        ///     向服务器共享文件程序台集合中添加新的共享台
        /// </summary>
        /// <param name="FiileShareProcessor" type="Hi_Baidu.FileShare.Interface.IFileShareProcessor">
        ///     <para>
        ///         新的共享台
        ///     </para>
        /// </param>
        public void Add(FileShareProcessor FileShareProcessor)
        {
            FileShareProcessors.Add(FileShareProcessor);
            OnAddFileShare(new OnAddFileShareEventArgs(FileShareProcessor));
        }

        #region 'OnAddFileShare' event definition code

        /// <summary>
        ///     EventArgs derived type which holds the custom event fields
        /// </summary>
        [Serializable]
        public class OnAddFileShareEventArgs : System.EventArgs
        {
            /// <summary>
            ///     Use this constructor to initialize the event arguments
            ///     object with the custom event fields
            /// </summary>
            public OnAddFileShareEventArgs(FileShareProcessor fileShareProcessorFileShareProcessor)
            {
                this.fileShareProcessor = fileShareProcessorFileShareProcessor;
            }

            /// <summary>
            ///     TODO: Describe the purpose of this event argument here
            /// </summary>
            public readonly FileShareProcessor fileShareProcessor;

        }
        #endregion //('OnAddFileShare' event definition code)

    }
}
